// columns.ts

import DictTag, { DictValueEnum } from "@/components/DictTag";
import { createIcon } from "@/utils/IconUtil";
import { MoreOutlined, PlusOutlined, EllipsisOutlined } from "@ant-design/icons";
import { ProColumns } from "@ant-design/pro-table";
import { Avatar, Button, Divider, Dropdown, MenuProps, Popconfirm, Space, Switch, Typography } from "antd";

// 定义所有列的工厂函数
export const createTableColumns = (
	handleColumnEditor: (record: API.System.DictType) => void,
	handleColumnDetailData: (record: API.System.DictType) => void,
	handleColumnRemove: (record: API.System.DictType) => void
): ProColumns<API.System.DictType>[] => {
	// const listOperItem: MenuProps["items"] = ;
	return [
		{
			title: "字典名称",
			dataIndex: "dictName",
			valueType: "text",
			width: 80,
			ellipsis: true
		},
		{
			title: "字典编码",
			dataIndex: "dictType",
			valueType: "text",
			width: 60
		},
		// {
		// 	title: "备注",
		// 	dataIndex: "remark",
		// 	valueType: "text"
		// },
		{
			title: "操作",
			dataIndex: "option",
			width: 20,
			fixed: "right",
			valueType: "option",
			render: (_, record: any) => {
				return (
					<>
						<Dropdown
							trigger={["click"]}
							menu={{
								items: [
									{
										label: (
											<Typography.Link
												key="edit"
												onClick={() => {
													handleColumnEditor(record);
												}}
											>
												编辑
											</Typography.Link>
										),
										key: "editor"
									},
									{
										label: (
											<Popconfirm
												placement="bottomRight"
												title={"提示"}
												description={`您确定要删除名为 ${record.dictName} 的字典吗`}
												onConfirm={() => {
													handleColumnRemove(record);
												}}
												okText="确认"
												cancelText="取消"
											>
												<Typography.Link type="danger" key="remove">
													删除
												</Typography.Link>
											</Popconfirm>
										),
										key: "remove"
									}
								]
							}}
						>
							<Button type="text" key="edit" icon={<EllipsisOutlined />} />
						</Dropdown>
					</>
				);
			}
		}
	];
};

export const dictTabs: any = [
	{
		key: "system",
		label: <span>系统字典</span>
	},
	{
		key: "biz",
		label: <span>业务字典</span>
	}
];

export const pagination = {
	// showQuickJumper: true,
	showSizeChanger: true
};

export const formTitle = ["添加字典类型", "编辑字典类型"];
